import qs from "qs";
import instance from "@/request/request";
import { pa } from "element-plus/es/locale";
export const getProductListApi = (
  params: any
): RES<ITableResult<IProductModel>> =>
  instance.get("/product/list", { params }); // 商品列表

export const productCategoryApi = (
  parentId: number
): RES<ITableResult<IProductModel>> =>
  instance.get(`/productCategory/list/${parentId}`);

//   属性管理
export const productAttributeApi = (
  params: IUserListParams
): RES<ITableResult<productList>> =>
  instance.get("/productAttribute/category/list", { params }); // 表格列表

// export const productAttrcreateApi = (params: any): RES<any> =>
//   instance.post(`/productAttribute/category/creat`, qs.stringify(params)); //添加
export const productAttrcreateApi = (
  params: userListModel
): RES<userListModel> =>
  instance.post("/productAttribute/category/create", qs.stringify(params)); //添加

export const productAttrupdateApi = (
  params: userListModel
): RES<userListModel> =>
  instance.post(
    `/productAttribute/category/update/${params.id}?name=${params.name}`
  ); //修改属性

export const productAttrDeleteApi = (params: any): RES<any> =>
  instance.get(`/productAttribute/category/delete/`, params); // 删除

export const productAttributeListApi = (id: number, params: IUserListParams): RES<ITableResult<AttriButeList>> =>
  instance.get(`/productAttribute/list/${id}`, { params }); //根据分类查询属性列表或参数列表

export const ProductAttriButeCreateApi = () =>
  instance.post("/productAttribute/create"); // 添加商品属性信息

// 品牌管理
export const BrandListApi = (params: any): RES<ITableResult<BrandListAll>> =>
  instance.get("/brand/list", { params }); //获取表格信息

export const BrandUpdatefactoryStatusApi = (
  id: number,
  factoryStatus: number
): RES<Number> =>
  instance.post(
    `/brand/update/factoryStatus/?ids=${id}&factoryStatus=${factoryStatus}`
  ); //品牌制造商

export const BrandUpdateshowStatusApi = (
  id: number,
  showStatus: number
): RES<Number> =>
  instance.post(`/brand/update/showStatus/?ids=${id}&showStatus=${showStatus}`); //品牌制造商

export const BrandDeleteApi = (id: number): RES<number> =>
  instance.get(`/brand/delete/${id}`); //删除

export const BrandCreateApi = (
  params: BrandCreateidModel
): RES<BrandCreateidModel[]> => instance.post("/brand/create", params); //添加

export const brandEditApi = (id: number): RES<BrandCreateidModel[]> =>
  instance.get(`/brand/${id}`); // 编辑

export const brandUpdateEditApi = (
  id: number,
  params: any
): RES<BrandCreateidModel[]> => instance.post(`/brand/update/${id}`, params); // 编辑

// 商品分类
export const ProductCategoryListApi = (parentId: number, params: IUserListParams): RES<ITableResult<ProductCategoryList>> => instance.get(`/productCategory/list/${parentId}`, { params }) //表格

export const ProductCategoryUpdatenavStatusApi = (id: number, navStatus: number): RES<number> => instance.post(`/productCategory/update/navStatus/?ids=${id}&navStatus=${navStatus}`) //导航栏

export const ProductCategoryUpdateshowStatusApi = (id: number, showStatus: number): RES<number> => instance.post(`/productCategory/update/showStatus/?ids=${id}&showStatus=${showStatus}`) //是否显示

export const ProductCategoryDeleteApi = (id: number): RES<number> => instance.post(`/productCategory/delete/${id}`) //删除

export const ProductCategoryCreateApi = (params: any): RES<ProductCategoryCreateModel> => instance.post("/productCategory/create", params)//添加

export const ProductCategoryListWithChildrenApi = (): RES<ProductCategoryList[]> => instance.get("/productCategory/list/withChildren") //查询所有一级分类及子分类

export const ProductCategoryApi = (id: number, params: ProductCategoryCreateModel): RES<ProductCategoryCreateModel> => instance.get(`/productCategory/${id}`, { params }) //根据id获取商品分类

export const ProductCategoryUpdateApi = (id: number, params: ProductCategoryCreateModel): RES<ProductCategoryCreateModel> => instance.post(`/productCategory/update/${id}`, params) //编辑

export const ProductCategoryListwithAttrApi = (): RES<ProductAttributeModel[]> => instance.get("/productAttribute/category/list/withAttr")



// 获取所有商品优选
export const prefrenceAreaListAllApi = (): RES<IPrefrenceAreaListAll[]> =>
  instance.get("/prefrenceArea/listAll");

// 获取全部商品专题
export const subjectListAllApi = (): RES<ISubjectListAll[]> =>
  instance.get("/subject/listAll");

// 查询所有一级分类及子分类
export const getProductCategoryWithChildrenListApi = (): RES<IProductCategory[]> => instance.get("/productCategory/list/withChildren")

// 创建商品
export const addProducCreatetApi = (params: any): RES<{}> => instance.post("/product/create", params)
